import { _decorator, Component, Node } from 'cc';
import { ProcedureDefine } from './game/define/ProcedureDefine';
import ProcedureLaunch from './game/procedure/ProcedureLaunch';
import ProcedureLoading from './game/procedure/ProcedureLoading';
import gfw from '../../extensions/gfw3_x/assets/scripts/gfw/gfw';
import { UIConfig } from './game/config/UIConfig';
import { director } from 'cc';
import CCCExtension from '../../extensions/gfw3_x/assets/scripts/gfw/extension/CCCExtension';
// import { checkLogin } from './api/Account';
// import pb from './pb/pbutils';
// import pb from './pb/pbutils';
const { ccclass, property } = _decorator;

@ccclass('GameLaunch')
export class GameLaunch extends Component {
    protected onLoad(): void {
        director.addPersistRootNode(this.node);
        gfw.init();
        gfw.ui.init(this.node, UIConfig);
        gfw.http.baseUrl = `http://localhost:4000`;
    }

    async start() {
        CCCExtension.init();
        const procedureMgr = gfw.procedure;
        procedureMgr.registerProcedure(ProcedureDefine.Launch, ProcedureLaunch);
        procedureMgr.registerProcedure(ProcedureDefine.Loading, ProcedureLoading);
        procedureMgr.changeState(ProcedureDefine.Launch);
    }

    update(deltaTime: number) {
        gfw.procedure.update(deltaTime);
    }
}

